//
//  JavascriptForm.h
//  iCodeMac
//
//  Created by Andrew Barry on 14/03/09.
//  Copyright 2009 Barry Computer Services. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "ProjectDocument.h"

@class FormView;
@class FormControl;
@class FormEditor;
@class SourceTextView;
@class JavascriptProject;

@interface JavascriptForm : ProjectDocument {
	IBOutlet FormView *formview;
	IBOutlet SourceTextView *textview;
	IBOutlet NSPopUpButton *objectPopup, *eventPopup;
	
	NSDictionary *saved;
	NSMutableArray *objectPopupReferences;
	FormControl *currentEditorControl;
	NSString *currentEditorEvent;
}
+(bool)precompileForm: (NSString *) path;
+(bool)optimiseForm: (NSMutableDictionary *) form;
+(bool)verifyForm: (NSString *) path forProject: (JavascriptProject *) project;

-(void)commitTextView;
-(void)actionPropChange: (NSArray *)data;
-(void)propChange: (NSArray *)data;
-(void)rebuildObjectPopup;
-(void)selectedObjectChanged: (id) sender;
-(void)selectedEventChanged: (id) sender;
-(void)selectPopupControl: (FormControl *)name;
-(void)selectEvent: (NSString *) eventName;
-(FormControl *) selectedPopupControl;
-(NSString *) selectedEvent;
-(void)editEvent: (NSString *) eventName forObject: (FormControl*) ctl;
-(void)updateCurrentEvent;
-(void)reloadEventPopup;
-(void)editorSelectedControl:(FormControl *) ctl;
-(FormEditor *) editor;
-(void) updateEditEnabled;
-(FormControl *) controlByName: (NSString *) controlName;
-(void)showError: (NSString *) message atLine: (int) nLine;
-(void) showError: (NSString *) message withHeader: (NSString *) header;

@end
